import socket

server_addr = ('192.168.2.12', 8080)

def main():
    tcp_client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

    tcp_client_socket.connect(server_addr)

    download_file_name = input('请输入要下载的文件名: ')

    tcp_client_socket.send(download_file_name.encode('utf-8'))

    recv_data = tcp_client_socket.recv(1024*1024)

    with open("new_" + download_file_name, 'wb') as f:
        f.write(recv_data)

    tcp_client_socket.close()

if __name__ == '__main__':
    main()